package validator

import "regexp"

type linkType struct{}

var linkReg = regexp.MustCompile("^[A-z0-9_=+\\-.:/]+$")

func (t *linkType) Validate(name string, val string, required bool) (bool, string) {
	if val == "" {
		if required {
			return false, name + "不能为空"
		}
		return true, ""
	}

	if !linkReg.MatchString(val) {
		return false, name + "应为网址链接"
	}

	return true, ""
}
